package filepro.file;

import java.io.*;

/**
 * 缓冲流
 * @author small瑞
 */
public class Buffer {
    public static void main(String[] args) throws IOException {
        String path = "G:\\IO\\山海经/南山开篇.txt";
        File file = new File(path);
        File file1 = new File("G:\\IO\\山海经/南山篇.txt");
        if(!file1.exists()){
            file1.createNewFile();
        }
        InputStream inputStream = new FileInputStream(file);

        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream,2<<9);

        OutputStream outputStream  = new FileOutputStream(file1);


        System.out.println(bufferedInputStream.markSupported());
        byte[] bytes = new byte[2<<3];
        int cur;
        while((cur =bufferedInputStream.read(bytes))!=-1){
            System.out.println(new String(bytes,0,cur));
        }


        outputStream.flush();
        outputStream.close();
        bufferedInputStream.close();
        inputStream.close();
    }
}
